<?php
/**
 * @package Green Realty component
 * @copyright (C) 2012 Greenkey studio. All rights reserved
 * @license GNU/GPL Version 2 - http://www.gnu.org/licenses/gpl-2.0.html
 * @author Greenkey studio
 */

// No direct access to this file
defined('_JEXEC') or die;

/**
 * GRealty component helper.
 */
abstract class GRealtyHelper
{
	/**
	 * Configure the Linkbar.
	 */
	public static function addSubmenu($submenu)
	{
		JSubMenuHelper::addEntry(JText::_('COM_GREALTY_SUBMENU_GRPARAMS'),
		                         'index.php?option=com_grealty', $submenu == 'grparams');
		JSubMenuHelper::addEntry(JText::_('COM_GREALTY_SUBMENU_CATEGORIES'),
		                         'index.php?option=com_categories&view=categories&extension=com_grealty',
		                         $submenu == 'categories');
		// set some global property
		$document = JFactory::getDocument();
		$document->addStyleDeclaration('.icon-48-grealty ' .
		                               '{background-image: url(../media/com_grealty/images/grlogo48.png);}');
		if ($submenu == 'categories')
		{
			$document->setTitle(JText::_('COM_GREALTY_ADMINISTRATION_CATEGORIES'));
            // Maybe if icon ot appear (Not work, it must be create the view file
            // JToolBarHelper::title(JText::_('COM_GREALTY_ADMINISTRATION_CATEGORIES'), 'grealty');
		}
	}
	public static function getActions($paramId = 0)
	{
		jimport('joomla.access.access');
		$user	= JFactory::getUser();
		$result	= new JObject;

		if (empty($paramId)) {
			$assetName = 'com_grealty';
		}
		else {
			$assetName = 'com_grealty.param.'.(int) $paramId;
		}

		$actions = JAccess::getActions('com_grealty', 'component');

		foreach ($actions as $action) {
			$result->set($action->name, $user->authorise($action->name, $assetName));
		}

		return $result;
	}
}
?>
